import 'package:flutter/material.dart';

// 横向列表
void main()=>runApp(myapp());

class myapp extends StatelessWidget{
  @override
  Widget build(BuildContext context){
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title:new Text('横向列表')
        ),
        body: Center(
          child: Container(
            height: 200.0,
            width: 180.0,
            color: Colors.orange,
            child: list(),
          ),
        )
      ),
    );
  }
}

// 单独把列表组件抽离出来使用，上面就不会显示太多太乱得嵌套
class list extends StatelessWidget{
  @override
  Widget build(BuildContext context){
    return new ListView(
              scrollDirection: Axis.horizontal, //横向滚动  Axis.vertical 纵向滚动(不知道为什么这里用不行)
              children: <Widget>[
                new Container(
                  width:170.0,
                  color: Colors.yellow,
                ),
                new Container(
                  width:170.0,
                  color:Colors.green,
                ),
                new Container(
                  width:170.0,
                  color:Colors.red,
                ),
                new Container(
                  width:170.0,
                  color:Colors.blue
                )
              ],
            );
  }
}